package sales.gz.com.salescounter.bean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017-06-26.
 */

public class ProductsBean implements Serializable {
    private int shop_product_id;//商品ID
    private String product_name;//商品名称
    private int box_no;//格子（货道号）0代表暂时缺货，其他的代表正常

    public int getShop_product_id() {
        return shop_product_id;
    }

    public void setShop_product_id(int shop_product_id) {
        this.shop_product_id = shop_product_id;
    }

    public int getBox_no() {
        return box_no;
    }

    public void setBox_no(int box_no) {
        this.box_no = box_no;
    }

    public String getProduct_name() {
        return product_name;
    }

    public void setProduct_name(String product_name) {
        this.product_name = product_name;
    }

    public static List<ProductsBean> parse(JSONArray jsonArray) throws JSONException{
        List<ProductsBean> productslist = new ArrayList<ProductsBean>();
        for (int i = 0;i<jsonArray.length();i++){
            JSONObject jsonObject = new JSONObject(jsonArray.get(i).toString());
            ProductsBean bean = new ProductsBean();
            bean.setShop_product_id(jsonObject.getInt("shop_product_id"));
            bean.setProduct_name(jsonObject.getString("product_name"));
            bean.setBox_no(jsonObject.getInt("box_no"));
            productslist.add(bean);
        }
        return productslist;
    }
}
